﻿using MarriageFertility.Mcm;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.ComponentInterfaces;
using TaleWorlds.Core;

namespace MarriageFertility.Models;

public class MfAgeModel : AgeModel
{
    private readonly AgeModel _previousModel;

    public MfAgeModel(AgeModel previousModel)
    {
        _previousModel = previousModel;
    }

    public override void GetAgeLimitForLocation(CharacterObject character, out int minimumAge, out int maximumAge,
        string additionalTags = "")
    {
        _previousModel.GetAgeLimitForLocation(character, out minimumAge, out maximumAge, additionalTags);
    }

    public override float GetSkillScalingModifierForAge(Hero hero, SkillObject skill, bool isByNaturalGrowth)
    {
        return _previousModel.GetSkillScalingModifierForAge(hero, skill, isByNaturalGrowth);
    }

    public override int BecomeInfantAge => _previousModel.BecomeInfantAge;
    public override int BecomeChildAge => _previousModel.BecomeChildAge;
    public override int BecomeTeenagerAge => _previousModel.BecomeTeenagerAge;
    public override int HeroComesOfAge => _previousModel.HeroComesOfAge;

    public override int BecomeOldAge
    {
        get
        {
            if (MCMSettings.Instance.HeroOldAge < 47) MCMSettings.Instance.HeroOldAge = 47;
            return MCMSettings.Instance.HeroOldAge;
        }
    }

    public override int MaxAge
    {
        get
        {
            if (MCMSettings.Instance.HeroOldAge < 47) MCMSettings.Instance.HeroOldAge = 47;
            return MCMSettings.Instance.HeroOldAge * 2;
        }
    }
}